package com.student.servlet;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.student.dao.*;
import com.student.model.*;

@WebServlet("/ShowCourseServlet")
public class ShowCourseServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public ShowCourseServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		CourseDao cd = new CourseDao();
		List<Course> courseList = (List<Course>) cd.getCourseList();
		request.setAttribute("courseList", courseList);
		HttpSession session = request.getSession();
		session.setAttribute("courseList", courseList);
		request.getRequestDispatcher("/view/teacher/showAllCourse.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
